import React from 'react';

import './index.less';

import {base} from 'nc-lightapp-front';

const {NCMenu} = base;

const {NCSubMenu, Item} = NCMenu;


export default class MainRowOperator extends React.Component {
    constructor(props) {
        super(props);
    }

    render() {
        const {
            language,
            onClick,
            record,
            index,
            btnConf
        } = this.props;

        // 自由=-1,提交=3,审批进行中=2,审批通过=1,审批未通过=0,已发Offer=4,接受Offer=5,拒绝Offer=6,待入职=7,拒绝入职=8,已入职=102
        // 目前只有 待入职=7,拒绝入职=8,已入职=102 三种状态
        let workState = record.values['workflow_state'].value;

        return (
            <div
                className="main-table-operator-btn"
                ref={ref => this.opt = ref}
            >
                {/* 拒绝入职时没有任何 操作 但可双击查看详情 */}
                {workState !== '8' && <NCMenu
                    mode="vertical"
                    className="main-table-operator-menu"
                    onClick={({item, key, keyPath}) => {
                        onClick(key, record, index);
                    }}
                    selectedKeys={[]}
                >
                    <NCSubMenu
                        title={language['gx6008-000046']/* "操作" */}
                        className="sub-menu-dom"
                    >
                        {/*待入职=7*/}
                        <If condition={workState === '7'}>
                            {btnConf.findIndex(btn => btn.key === 'chgbegindate') > -1 ?
                                <Item
                                    key="adjust"
                                >
                                    <a href="javascript:void(0)">
                                        {language['gx6008-000219']/** 调整计划入职日期 */}
                                    </a>
                                </Item> : null}
                            {btnConf.findIndex(btn => btn.key === 'handle') > -1 ?
                                <Item
                                    key="handle"
                                >
                                    <a href="javascript:void(0)">
                                        {language['gx6008-000222']/** 入职办理 */}
                                    </a>
                                </Item> : null}
                            {btnConf.findIndex(btn => btn.key === 'reject') > -1 ?
                                <Item
                                    key="refuse"
                                >
                                    <a href="javascript:void(0)">
                                        {language['gx6008-000010']/** 拒绝入职 */}
                                    </a>
                                </Item> : null}
                        </If>
                        {/*已入职=102*/}
                        <If condition={workState === '102'}>
                            {btnConf.findIndex(btn => btn.key === 'missremind') > -1 ?
                                <Item
                                    key="sendmiss"
                                >
                                    <a href="javascript:void(0)">
                                        {language['gx6008-000223']/** 发送缺件提醒 */}
                                    </a>
                                </Item> : null}
                            {btnConf.findIndex(btn => btn.key === 'confreceive') > -1 ?
                                <Item
                                    key="confrec"
                                >
                                    <a href="javascript:void(0)">
                                        {language['gx6008-000224']/** 确认收件 */}
                                    </a>
                                </Item> : null}
                        </If>
                    </NCSubMenu>
                </NCMenu>}
            </div>
        );
    }
}